#! /usr/bin/python

import random

TR = open('../Data_Sets/file-true.bin', 'r')
TF = open('../Data_Sets/file-true-Binary.bin', 'w')
SR = open('../Data_Sets/file-rand.bin', 'r')
SF = open('./file-rand-Binary.bin', 'w')
RR = open('../Data_Sets/file-srandSeed.bin', 'r')
RF = open('../Data_Sets/file-srandSeed-Binary.bin', 'w')
MR = open('../Data_Sets/Mersene_Twister.bin', 'r')
MF = open('../Data_Sets/Mersene_Twister-Binary.bin', 'w')

def Denary2Binary(n):
	'''convert denary integer n to binary string bStr'''
	bStr = ''
	if n < 0: raise ValueError, "must be a positive integer"
	if n == 0: return '0'
	while n > 0:
		bStr = str(n % 2) + bStr
		n = n >> 1
	return bStr

def int2bin(n, count=24):
	"""returns the binary of integer n, using count number of digits"""
	return "".join([str((n >> y) & 1) for y in range(count-1, -1, -1)])

for line in TR:
	TF.write(Denary2Binary(int(line))+"\n")

for line in SR:
	SF.write(Denary2Binary(int(line))+"\n")

for line in RR:
	RF.write(Denary2Binary(int(line))+"\n")

for line in MR:
	MF.write(Denary2Binary(int(line))+"\n")

TR.close()
TF.close()
SR.close()
SF.close()
RR.close()
RF.close()
MR.close()
MF.close()
